<template>
  <el-dialog
    v-if="visible"
    title="审批驳回"
    :visible.sync="visible"
     width="30%"
    :before-close="handleCancel"
    destroy-on-close
    class="dialog-form"
    >
        <el-form ref="reject-form" size="medium"  :model="form" :rules="rules" label-width="120px">  
            <el-form-item label="审批意见：" prop="operationOpinion">
                <el-input 
                v-model.trim="form.operationOpinion" 
                placeholder="请输入审批意见" 
                type="textarea"
                rows="3" 
                maxlength="50"
                show-word-limit
                >
                </el-input>
            </el-form-item>
            <el-form-item label="电子签名：" prop="operatorSignature">
                <Signature v-if="visible" :applicant-signature.sync="form.operatorSignature" type-name="审批"></Signature>
            </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <BaseButton type="second" :throttle-time="200" @click="handleCancel">取 消</BaseButton>
            <BaseButton @click="handelConfirm">确 定</BaseButton>
        </div>
    </el-dialog>
</template>
<script>
import { value2Name } from '@/filters'
import { ApplicationModel } from '@/models'
export default {
    filters: {
        value2Name
    },
    props: {
        queryData: {
            type: Object,
            default: () => {}
        },
    },
    data() {
        return {
            model: new ApplicationModel(),
            visible: false,
            rules: {
                operationOpinion: [
                    { required: true, message: '请输入审批意见', trigger: 'blur' },
                ],
                operatorSignature: [
                    {required: true}
                ]
            },
            form: {
                id: '',
                operationOpinion: '',
                operatorSignature: '' // 电子签名
            }
           
        }
    },   
    methods: {
     
        // 取消
        handleCancel() {
            this.$refs['reject-form'].resetFields()
            this.$refs['reject-form'].clearValidate()
            this.visible = false
        },
        // 确定
        handelConfirm() {
            this.$refs['reject-form'].validate((valid) => {
                this.model.approvalReject({...this.form}).then(() => {
                    this.$message.success('操作成功!')
                    this.handleCancel()
                    this.$emit('updateData')
                })
            })
        },
       
    }
}
</script>
<style scoped lang="scss">

</style>
